/** 
 * @file	msp_time.c
 * @brief	
 * 
 *  This file implements system-independence time interface.
 * 
 * @author	hjma
 * @version	1.0
 * @date	2011-07-25
 * 
 * @see		
 * 
 * <b>History:</b><br>
 * <table>
 *  <tr> <th>Version	<th>Date		<th>Author	<th>Notes</tr>
 *  <tr> <td>1.0		<td>2011-07-25	<td>hjma	<td>Create this file</tr>
 * </table>
 * 
 */
#include "os.h"
#include "msp_time.h"

#if !(defined(WIN32) || defined(WINCE))

void msp_localtime(LPMSP_SYSTEMTIME lpSystemTime)
{
	struct tm* st,tmp_tm;
	time_t st_t;
	struct timeval tv;

	if ( lpSystemTime )
	{
		time(&st_t);
		st = localtime_r ( &st_t ,&tmp_tm);
		gettimeofday(&tv, 0);
		lpSystemTime->wYear = st->tm_year+1900;
		lpSystemTime->wMonth = st->tm_mon+1;
		lpSystemTime->wDayOfWeek = st->tm_wday;
		lpSystemTime->wDay = st->tm_mday;
		lpSystemTime->wHour = st->tm_hour;
		lpSystemTime->wMinute = st->tm_min;
		lpSystemTime->wSecond = st->tm_sec;
		lpSystemTime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
	}
}

#endif